import pandas as pd
import time
from makedir import FileOp
# ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# Press the green button in the gutter to run the script.
# =============================    程序入口    =============================
if __name__ == '__main__':
    pathFile = "day_file/SH#603227.txt"
    titleName = ['trade_date', 'trade_times', 'open', 'high', 'low', 'close', 'vol', 'amount']
    df = pd.read_table(pathFile, header=1, encoding="gbk", names=titleName, converters={'trade_times': str})
    # 删除最后一行SZ#399007.txt 5254    数据来源:通达信   NaN   NaN   NaN    NaN          NaN           NaN  1  1
    pd.set_option('display.expand_frame_repr', False)
    df.drop([len(df) - 1], inplace=True)
    df=df.loc[(df.trade_date>'2022/01/01') & (df.trade_date<='2022/01/14')]
    # df = df.loc[(df.trade_times=='1300')]
    # df['trade_times'] = 1130
    # df.replace(df['trade_times']==1500, 1130, inplace=True)

    df.loc[df['trade_times'] == '1300', 'trade_times'] = 1130

    # if(df['trade_times'] == '1300'):
    #     print("xxxxxxxxxxxxxxxxxxxx")
    print(df)
    # currentDate = time.strftime("%Y%m%d%H%M%S", time.localtime())
    currentDate = time.strftime("%Y%m%d", time.localtime())
    # FileOp.mkdir("e://stcokData//"+currentDate+"//stock_day_qfq//")
    # FileOp.mkdir("e://stcokData//" + currentDate + "//stock_5MIN_qfq//")
    # FileOp.mkdir("e://stcokData//" + currentDate + "//stock_1MIN_qfq//")
    # FileOp.mkdir("e://stcokData//" + currentDate + "//export//stock_5MIN_qfq//")
    # FileOp.mkdir("e://stcokData//" + currentDate + "//export//stock_5MIN_qfq//")
    # FileOp.mkdir("e://stcokData//" + currentDate + "//export//stock_DAY_qfq//")
    FileOp.mkdir("e://stcokData//" + currentDate + "//export//stock_all_qfq//")